import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
  path: '/',
  name: 'Layout',
  component: function () {
    return import('@/views/layout/index.vue')
  },
  children: [{
    path: '',
    name: 'Home',
    component: function () {
      return import('@/views/home/index.vue')
    },
  }]
}, ]

// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch((err) => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
})

export default router